#ifndef IMAGEWIDGET_H
#define IMAGEWIDGET_H

#include <QWidget>
#include "WpMediaFile.h"

class WPDataBlog;
class PopupMenu;

class QLabel;
class QPushButton;

class ImageWidget : public QWidget
{
    Q_OBJECT
public:
    explicit ImageWidget(const WPDataBlog& aBlog, const QPixmap& aPixmap, const QString& aFilename, QWidget *parent = 0);
    ~ImageWidget();
    int RotationAngle() const;
    const QSize& TargetSize() const;
    const QString& FileName() const;
    WPMediaFile::Align Alignment() const;
    WPMediaFile::SizeType SizeType() const;

signals:
    void removeClicked(ImageWidget* targetWidget);

public slots:

private:
    void mousePressEvent(QMouseEvent *e);
    void mouseMoveEvent(QMouseEvent *e);
    void mouseReleaseEvent(QMouseEvent *e);
    void keyPressEvent(QKeyEvent *e);
    void resizeEvent(QResizeEvent *e);
    QPoint getMenuLocation(QPoint itemPoint);
    void RefreshText();

private slots:
    void ShowContextMenu();
    void ShowResolutionMenu();
    void ShowAlignMenu();

    void MenuHidden();

    void AlignLeft();
    void AlignRight();
    void AlignBottom();
    void AlignTop();

    void ResizeOriginal();
    void ResizeThumbnail();
    void ResizeMedium();
    void ResizeLarge();
    void RotateLeft();
    void RotateRight();

    void doRemoveClicked();

private:
    const WPDataBlog&   iBlog;
    QPixmap             iPixmap;
    QString             iFilename;
    bool                iMouseDown;
    QPoint              iMousePos;
    PopupMenu         * iPopupMenu;
    int                 iRotationAngle;
    QSize               iTargetSize;
    QLabel            * iImage;
    QPushButton       * iAlignButton;
    QPushButton       * iResolutionButton;
    QLabel            * iTextLabel;
    WPMediaFile::Align  iAlignment;
    QString             iAlignText;
    WPMediaFile::SizeType iSizeType;
    QString               iSizeText;
};

#endif // IMAGEWIDGET_H
